let RDIR = require('./config.js').rootDir
let d = require('./d.js')
let inquirer = require('inquirer')
let f = require('./file.js')

let arr = d.outOfDate(RDIR)
console.log('正在查找可以删除的压缩包......')
arr.forEach((e) => console.log(e) )
if (arr.length === 0 ) return console.log('clear')

;(function start (arr) {
    let ele = arr.pop()
    inquirer.prompt([{ name: 'rm', message: 'remove regular empty file ' + ele + ' ?(y)' }])
            .then(function (answers) {
                    if (answers.rm === 'y' || answers.rm === '') f.rm(ele) 
                    if (answers.rm === '-r') {
                        f.rm(ele)
                        arr.forEach((e) => f.rm(e) )
                        arr.length = 0
                    }
                    if (arr.length !== 0 ) start(arr)
                })
    }(arr))